package com.diqizu.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import com.diqizu.entity.LunBo;
import com.diqizu.utli.DBManager;
import com.diqizu.utli.QueryDataResult;

/**
 * 
 *  ? ??  
 * 
 * @author       
 *
 */
public class LunBoDaoImpl {
  public ArrayList<LunBo> getALllb() {
    String sql = "select * from lunboinfo order by paixu desc";
    System.out.println("?查询的语句是:" + sql);
    QueryDataResult execQuery = DBManager.execQuery(sql);
    ArrayList<LunBo> list = new ArrayList<LunBo>();
    if (execQuery != null) {
      ResultSet rs = execQuery.rs;
      try {
        while (rs.next()) {
          LunBo e = new LunBo();
          e.setImagId(rs.getInt(1));
          e.setImageName(rs.getString(2));
          e.setImag(rs.getString(3));
          e.setDizhi(rs.getString(4));
          e.setPaixu(rs.getString(5));
          list.add(e);

        }
      } catch (SQLException e) {
        e.printStackTrace();
      } finally {
        execQuery.close();
      }
    }
    System.out.println(list);
    return list;
  }
  public  boolean getALllb2(LunBo lunBo) {
    String sql ="insert into lunboinfo (imageName,imag,dizhi,paixu) values('"+lunBo.getImageName()+"','"+lunBo.getImag()+"','"+lunBo.getDizhi()+"','"+lunBo.getPaixu()+"')";
    System.out.println("?查询的语句是:" + sql);
    return DBManager.execUpdate(sql);
  
  }
  public  boolean getALllb3(LunBo lunBo) {
    String sql ="update lunboinfo set imageName='"+lunBo.getImageName()+"',imag='"+lunBo.getImag()+"',dizhi='"+lunBo.getDizhi()+"',paixu='"+lunBo.getPaixu()+"' where imagId="+lunBo.getImagId();
    System.out.println("?查询的语句是:" + sql);
    return DBManager.execUpdate(sql);
  
  }
  public  boolean getALllb4(int imagId) {
    String sql ="delete from lunboinfo where imagId="+imagId;
    System.out.println("?查询的语句是:" + sql);
    return DBManager.execUpdate(sql);
  
  }
}
